from PyQt4 import QtGui, QtCore; #@UnusedImport

class Settings_ShapeStyle(QtCore.QObject):    
    def __init__(self, parent):
        super(Settings_ShapeStyle, self).__init__();
        self.parent = parent;
        self.mainWin = parent.mainWin;
        self.graphScene = parent.graphScene;
        self.createSettings_ShapeStyle();
        
    def onCbxStateClick(self, iVal):
        if iVal==0:
            self.setSt_RoundedRect();
        elif iVal==1:
            self.setSt_Rect();
        elif iVal==2:
            self.setSt_Circle();
        
    def onCbxActionClick(self, iVal):
        if iVal==0:
            self.setEdge_Spline();
        elif iVal==1:
            self.setEdge_Polygon();
            
    def updateSelectedSettings(self):
        self.onCbxStateClick(self.cbxState.currentIndex());
        self.onCbxActionClick(self.cbxAction.currentIndex());
        
    def createSettings_ShapeStyle(self):
        self.lblState = QtGui.QLabel("State:", self.mainWin);
        self.lblAction = QtGui.QLabel("Edge:", self.mainWin);
        self.cbxState = QtGui.QComboBox(self.mainWin);
        self.cbxState.addItems(["Rounded Rect", "Rect", "Circle"]);
        self.cbxState.connect(self.cbxState, 
                              QtCore.SIGNAL("currentIndexChanged(int)"), 
                              self.onCbxStateClick);
        self.cbxState.setMaximumWidth(100);
        self.cbxState.setMinimumWidth(100);
        self.cbxAction = QtGui.QComboBox(self.mainWin);
        self.cbxAction.addItems(["Spline", "Rect"]);
        self.cbxAction.connect(self.cbxAction, 
                               QtCore.SIGNAL("currentIndexChanged(int)"), 
                               self.onCbxActionClick);
        self.cbxAction.setMaximumWidth(100);
        self.cbxAction.setMinimumWidth(100);
        
        self.gridLayout = QtGui.QGridLayout();
        self.gridLayout.addWidget(self.lblState,0,0, 
                                  QtCore.Qt.AlignRight);        
        self.gridLayout.addWidget(self.cbxState,0,1, QtCore.Qt.AlignLeft);        
        self.gridLayout.addWidget(self.lblAction,1,0, 
                                  QtCore.Qt.AlignRight);
        self.gridLayout.addWidget(self.cbxAction,1,1, QtCore.Qt.AlignLeft);
        
        self.qWidget = QtGui.QWidget(self.mainWin);
        self.qWidget.setLayout(self.gridLayout);
        self.vBoxMain = QtGui.QVBoxLayout();
        self.vBoxMain.addWidget(self.qWidget); 
    
    #Graph - Shape Style Cmds        
    def setSt_Rect(self):
        self.graphScene.graphView.setNodes_StateShape(0);      
    def setSt_RoundedRect(self):
        self.graphScene.graphView.setNodes_StateShape(15);
    def setSt_Circle(self):
        self.graphScene.graphView.setNodes_StateShape(80); 
    def setEdge_Polygon(self):
        self.graphScene.graphView.setEdges_LineType(1);
    def setEdge_Spline(self):
        self.graphScene.graphView.setEdges_LineType(2);

        
    def getDataSettings(self):
        aDataSettings = [];
        aDataSettings.append(self.cbxState.currentIndex());
        aDataSettings.append(self.cbxAction.currentIndex());
        return aDataSettings;
    
    def setDataSettings(self, aDataSettings):
        self.cbxState.setCurrentIndex(aDataSettings[0]);
        self.cbxAction.setCurrentIndex(aDataSettings[1]);
        self.updateSelectedSettings();
